function game(playerAction) {
  const arr = ['rock', 'paper', 'scissor']
  const index = Math.floor(Math.random() * arr.length);
  const computerAction = arr[index];

  console.log(`我出了：${computerAction}`);

  if (playerAction === computerAction) {
    console.log('平局');
    return 0
  } else if ((playerAction === 'rock' && computerAction === 'scissor') ||
    (playerAction === 'paper' && computerAction === 'rock') ||
    (playerAction === 'scissor' && computerAction === 'paper')) {
    console.log('胜利');
    return 1
  } else {
    console.log('败北');
    return -1
  }
}

module.exports = {
  game
}